package com.jeesite.modules.jdProduct.service;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.jdProduct.dao.ZtAfterSaleDao;
import com.jeesite.modules.jdProduct.entity.ZtAfterSale;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName AfterSaleService
 * @description
 * @Author ouyang
 * @Date 2019/4/30 14:03
 **/
@Service
@Transactional(readOnly = true)
public class ZtAfterSaleService extends CrudService<ZtAfterSaleDao, ZtAfterSale> {


    public ZtAfterSale findBySkuId(ZtAfterSale afterSale){
        return dao.findBySkuId(afterSale);
    }

    /**
     *  根据服务号查询
     * @param afterSale
     * @return
     */
    public ZtAfterSale findByAfsServiceId(ZtAfterSale afterSale){
        return dao.findByAfsServiceId(afterSale);
    }

    /**
     * 获取单条数据
     *
     * @param afterSale
     * @return
     */
    @Override
    public ZtAfterSale get(ZtAfterSale afterSale) {
        ZtAfterSale entity = super.get(afterSale);
        if (entity == null) {
            entity = new ZtAfterSale();
        }
        return entity;
    }

    public List<ZtAfterSale> findGhMh(ZtAfterSale afterSale) {
        return dao.findGhMh(afterSale);
    }

    /**
     * 查询分页数据
     *
     * @param page
     *            分页对象
     * @param afterSale
     * @return
     */
    @Override
    public Page<ZtAfterSale> findPage(Page<ZtAfterSale> page,
                                      ZtAfterSale afterSale) {
        return super.findPage(page, afterSale);
    }

    /**
     * 保存数据（插入或更新）
     *
     * @param afterSale
     */
    @Override
    @Transactional(readOnly = false)
    public void save(ZtAfterSale afterSale) {
        super.save(afterSale);

    }

    /**
     * 更新状态
     *
     * @param afterSale
     */
    @Override
    @Transactional(readOnly = false)
    public void updateStatus(ZtAfterSale afterSale) {
        super.updateStatus(afterSale);
    }

    /**
     * 删除数据
     *
     * @param afterSale
     */
    @Override
    @Transactional(readOnly = false)
    public void delete(ZtAfterSale afterSale) {
        super.delete(afterSale);
    }

    /**
     *  根据订单状态查询
     * @param asList
     * @return
     */
    public List<ZtAfterSale> findByAfsServiceStepInList(List<Integer> asList) {
        return dao.findByAfsServiceStepInList(asList);
    }
}
